package com.cloud.wms.ui.sort.detach;

import android.content.Intent;
import android.os.Message;

import com.cloud.widget.ScanText;
import com.cloud.wms.R;
import com.cloud.wms.base.BaseBarActivity;
import com.cloud.wms.config.IntentKey;
import com.cloud.wms.ui.sort.contract.DetachContact;
import com.cloud.wms.ui.sort.entity.DetachDetailBean;
import com.cloud.wms.ui.sort.presenter.DetachPresenter;

import java.io.Serializable;
import java.util.List;

import butterknife.BindView;

/**
 * Created by FC on 2021/3/8.
 * Desc：
 */
public class DetachStartActivity extends BaseBarActivity<DetachPresenter> implements DetachContact.View {
    @BindView(R.id.scan_text)
    ScanText scanText;

    @Override
    protected String barTitle() {
        return "二次分拨";
    }

    @Override
    protected int getResId() {
        return R.layout.activity_second_allocation_start;
    }

    @Override
    protected void onScanHandle(String result, int resultCode) {
        super.onScanHandle(result, resultCode);
        scanText.addHistory(result);
        mPresenter.loadBatchDetail(result);
    }

    @Override
    protected void initEvent() {
        initScanText(scanText);
    }

    @Override
    public void onSuccess(Message message) {
        if (message.what == DetachPresenter.GET_BATCH_DETAIL_SUCCESS) {
            List<DetachDetailBean> detailBeanList = (List<DetachDetailBean>) message.obj;
            Intent intent = new Intent(this, DetachBindActivity.class);
            intent.putExtra(IntentKey.OBJECT_KEY, (Serializable) detailBeanList);
            startActivity(intent);
        }
    }

    @Override
    protected void setupComponent() {
        getActivityComponent().inject(this);
    }
}
